package net.wofly.sale.stock.service;

import net.wofly.common.persistence.PageWrapper;
import net.wofly.framework.util.ReturnBean;
import net.wofly.sale.report.domain.ResourceAskDTO;
import net.wofly.sale.stock.domain.ResourceAsk;
import net.wofly.sale.stock.domain.ResourceAskList;
import net.wofly.sale.stock.dto.ResourceAskStatusDTO;

import java.util.List;
import java.util.Map;

/**
 * 领料申请服务类
 *
 * @author lign
 * @version 1.0
 * @created 29-9月-2017 21:43:54
 */
public interface IResourceAskService {
    
    /**
     * 增加或修改
     *
     * @param entity
     * @return
     */
    public ResourceAsk save(ResourceAsk entity);
    
    /**
     * 删除
     *
     * @param entity
     * @return
     */
    public void delete(ResourceAsk entity);
    
    /**
     * 根据主键ID删除
     *
     * @param key
     * @return
     */
    public void delete(String key);
    
    /**
     * 根据主键查询
     *
     * @param key
     * @return
     */
    public ResourceAsk findOne(String key);
    
    public List<ResourceAsk> save(List<ResourceAsk> entityList);
    
    /**
     * 领料申请审核
     * <ul>
     * <li>判断当前用户是否有权限进行审核</li>
     * <li></li>
     * </ul>
     *
     * @param resourceAskID
     */
    public ReturnBean<String> checkResourceAsk(String resourceAskID, Integer checkStatus, String checker);
    
    /**
     * 提交领料申请进行审核
     *
     * @param resourceAskID
     */
    public ReturnBean<String> commitResourceAsk(String resourceAskID, String commiter);
    
    /**
     * @param resourceAskID
     */
    public ReturnBean<String> consign(String resourceAskID, String consigner);
    
    /**
     * 删除领料申请
     * <ul>
     * <li>一旦提交不可删除</li>
     * <li></li>
     * </ul>
     *
     * @param resourceAskID
     */
    public ReturnBean<String> delResourceAsk(String resourceAskID,String userID);
    
    /**
     * 领料出库
     * <ul>
     * <li>判断当前用户是否有限制进行出库</li>
     * <li>从出库人所在仓库中减去出库商品数量，并记录出库流水</li>
     * <li>加到申请人所在的入库商品数量，并记录入库流水</li>
     * <li></li>
     * </ul>
     *
     * @param resourceAskID
     */
    public ReturnBean<String> outStock(String resourceAskID);
    
    /**
     * 打印发货单
     *
     * @param resourceAskID
     */
    public ReturnBean<ResourceAsk> printConsign(String resourceAskID);
    
    /**
     * 保存领料申请
     *
     * @param resourceAskLists
     * @param asker
     */
    public ReturnBean<ResourceAsk> saveResourceAsk(String resourceAskID ,List<ResourceAskList> resourceAskLists, String asker);
    
    /**
     * @param resourceAsk
     */
    public ReturnBean<ResourceAsk> updateResourceAsk(ResourceAsk resourceAsk);

    /**
     * 领料申请单详情
     *
     * @param resourceAskID
     */
    public ReturnBean<ResourceAsk> getResourceAsk(String resourceAskID);

    /**
     * 获取领料申请单
     * <ol>
     * 	<li> askStatus=-1时，表示取所有状态的申请单</li>
     * </ol>
     *
     * @param askNO
     * @param askUserID
     * @param askStatus
     * @param pageNum
     * @param pageSize
     */
    public ReturnBean<PageWrapper<ResourceAsk>> getResourceAskList(String askNO, String askUserID, Integer askStatus, Integer pageNum, Integer pageSize);

    public ReturnBean<List<ResourceAskStatusDTO>> getResourceAskStatus();
    
    /**
     * 通过工作流实例ID列表查找所有ID的领料申请
     * 
     * @param processInsIDs
     * @return
     */
    public List<ResourceAsk> findByInProcessInsID(List<String> processInsIDs);
    
    /**
     * 通过工作流实例ID查找ID的领料申请
     * 
     * @param processInsID
     * @return
     */
    public ResourceAsk findByProcessInsID(String processInsID);
    
    /**
     * 获取领料工作流待办
     * 
     * @param userId
     * @return
     */
    public List<ResourceAsk> findToDoList(String userId) ;
	
	/**
	 * 获取领料工作流详情
	 * 
	 * @param resourceAskID
	 * @return
	 */
	public ReturnBean<ResourceAsk> getResourceAskForFlow(String resourceAskID) ;
	
	/**
	 * 批准还货
	 * 
	 * 工作流中同意还货请求后，回调此方法，修改公司库存及申请人库存
	 * 
	 * @param resourceAskID
	 */
	public void approveResourceAsk(String resourceAskID) ;
	
	/**
	 * 领料单提交审核
	 * 
	 * @param userId
	 * @param resourceAskID
	 * @return
	 */
	public ReturnBean<String> startWorkflow(String userId ,String resourceAskID,Map<String, Object> variables) ;

    /**
     * 查询领料数量
     *
     * @param countDate
     * @param countEndTime
     * @return
     */
    List<ResourceAskDTO> findByCountDate(Long countDate, Long countEndTime);
    
    /**
     * 向用户的领料申请草稿中增加终端商品
     * 当前用户有草稿时，直接加到草稿中，没有草稿则新建一个草稿，将商品加到草稿中
     * 
     * @param userID
     * @param commodityTerminalID
     * @return
     */
    public ReturnBean<ResourceAsk> addResourceAskDraft(String userID ,String commodityTerminalID ,Integer askNum) ;
    
    /**
     * 获取当前用户领料草稿
     * 
     * 
     * @param userID
     * @return
     */
    public ReturnBean<ResourceAsk> getResourceAskDraft(String userID) ;
    
    /**
     * 删除领料内容
     * 
     * @param resourceAskListID
     * @return
     */
    public ReturnBean<String> delResourceAskList(String resourceAskListID);
    
    
}